<template>
  <div class="header">
      <div class="left">
        <icon class="sysylogo"></icon>
        <h2>鹰潭仲裁委管理平台</h2>
      </div>
      <div class="right">
        <span class="user arbgright needDeal" @click="needDeal">待办：{{this.$store.state.dealThing}}
          <span class="badge" v-show="this.$store.state.dealThing>0"><Badge dot status="processing" text="Processing">
              <a href="#" class="demo-badge"></a>
          </Badge></span>
        </span>
        <span class="arbgright">用户：{{this.$store.state.username}}</span>
        <span class="user arbgright">角色：{{this.$store.state.rolename}}</span>
        <span class="loginout arbgright" @click="loginOut">退出</span>
      </div>
      
    
  </div>
</template>

<script>
export default {
  name: 'Header',
  data(){
    return {
      rolename:'',
      username:'',
      dealThing:''
    }
  },
  props: {
    msg: String
  },
  methods:{
    loginOut(){
      this.$http.get('/api'+this.urls.logout).then((result)=>{
                if(result.data.code===200){
                  this.$Message.success('退出成功');
                  // clearInterval(this.settimes)
                  localStorage.setItem('username','')
                  localStorage.setItem('rolename','')
                  localStorage.setItem('userid','')
                  localStorage.setItem('roleid','')
                  
                  this.$store.dispatch('changeRolename','')
                  this.$store.dispatch('changeUsername','')
                  this.$store.dispatch('changeUserid','')
                  this.$store.dispatch('changeRoleid','')
                  // setTimeout(()=>{
                   
                       this.$router.push('/arbitLogin')
                    
                   
                  // },500)
                  localStorage.setItem('userinfo','')
                }else{
                  this.$Message.warning('网络错误');
                }
      })
    },
    needDeal(){
       if(localStorage.getItem('roleid')=='arbSecretary'&&this.$route.name!='VerifycommissionerIndex'){
             this.$router.push('/Syspage/VerifycommissionerIndex');
             setTimeout(()=>{
                this.$store.commit('needAmont',Math.random())
              },100)
      }else if(localStorage.getItem('roleid')=='arbDirector'&&this.$route.name!='VerifydirectorIndex'){
             this.$router.push('/Syspage/VerifydirectorIndex');
             setTimeout(()=>{
                this.$store.commit('needAmont',Math.random())
              },100)
      }else if(localStorage.getItem('roleid')=='arbPerson'&&this.$route.name!='ArbitratordirectorIndex'){
             this.$router.push('/Syspage/ArbitratordirectorIndex');
             setTimeout(()=>{
                this.$store.commit('needAmont',Math.random())
              },100)
      }else{
        this.$store.commit('needAmont',Math.random())
      }
    }
  },
  created(){
      // this.$http.get('/api'+this.urls.getTodoCaseCount).then((result)=>{
      //           if(result.data.code===200){
      //             this.dealThing=result.data.data.count
      //           }else{
      //             this.$Message.warning('网络错误');
      //           }
      // })
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
 .header{
   height: 82px;
   /* background: #4CAF50; */
   line-height: 82px;
   display: flex;
   justify-content: space-between;
   
 }
  h2{
    display: inline;
    color: #fff;
    vertical-align: text-bottom;
    line-height: 38px;
  }
  .right{
    /* margin-right: 14px; */
    color: #617991;
  }
  .sysylogo{
    height: 38px; 
    width: 39px;
    background: url('../../assets/arbitIcon.png');
    background-size: 100% 100%;
    margin-right: 10px;
  }
  /* .btn{
    background: #1a1d45;
    color: #617991;
    line-height: 50px;
    width: 160px;
    height: 50px;
    display: inline-block;
    margin: 0 10px;
    text-align: center;
    cursor: pointer;
  } */
  .user{
    margin: 0 50px;
  }
  .loginout{
    cursor: pointer;
  }
</style>
